<template>
	<!-- 结算item -->
	<view class="pull-number-item" @click="goPath">

		<view class="head">
			<view class="left">
				订单编号：<text class="code">{{info.code}} </text>
			</view>
			<view class="cart-code">
				{{info.hphm}}
			</view>
		</view>
		<!-- list -->
		<view class="nameList">
			<!-- <view class="nameItem" style="color: #2E87FF;">
				已完成
			</view> -->
			<view class="nameItem" style="color: #2E87FF;margin-left: 12rpx;" v-if="info.settlementStatus=='0'">
				待结算
			</view>
			<view class="nameItem" style="margin-left: 12rpx;background: rgba(57,183,145,0.1);
border-radius: 4rpx 4rpx 4rpx 4rpx;
border: 2rpx solid #39B791;color: #39B791;" v-if="info.settlementStatus=='3'">
				已结算
			</view>
			<view class="nameItem" style="margin-left: 12rpx;background: rgba(235,79,81,0.1);
border-radius: 4rpx 4rpx 4rpx 4rpx;
border: 2rpx solid #EB4F51;color: #EB4F51;" v-if="info.settlementStatus=='1'">
				不可结算
			</view>
		</view>
		<view class="center-box">
			<view class="left">
				<view class="addr-box start">
					<view class="icon-box">
						<view class="icon">
							起
						</view>
					</view>
					<view class="addr">
						{{info.startingPlace}}
					</view>
				</view>
				<view class="addr-box end">
					<view class="icon-box">
						<view class="icon">
							终
						</view>
					</view>
					<view class="addr">
						{{info.terminusPlace}}
					</view>
				</view>
			</view>
			<view class="right">
				<view class="status-box" :class="[info.transportStatus=='待签收'?'danger':'no']">
					<view class="status">
						
						{{info.transportStatus}}
					</view>
				</view>
			</view>
		</view>
		<view class="bottom-box">
			<up-grid col="2" gap="12rpx" class="top">
				<up-grid-item>
					<view class="item">

						<view class="title">
							创建时间
						</view>
						<view class="val">
							{{info.createTime}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							实际运输时长（分钟）
						</view>
						<view class="val">
							{{info.transportDuration||0}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
			<up-grid col="4" gap="12rpx" class="bottom">
				<up-grid-item>
					<view class="item">
						<view class="title">
							驾驶员
						</view>
						<view class="val" @click.stop="payHanle(info.phone)">
							<text>{{info.driverName}}</text>
							<image class="icon" src="/static/img/car/tell.png"></image>
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							签收人
						</view>
						<view class="val">
							{{info.signBy||'未签收'}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">

						<view class="title">
							类型
						</view>
						<view class="val">
							{{info.rockTypeName}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							方量
						</view>
						<view class="val primary">
							{{info.volume}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
		</view>
	</view>
</template>

<script setup lang="ts">
	
	import {  useDriverStore } from '@/stroes';
	const driverStore = useDriverStore()
	const props = defineProps({
		info: {
			type: Object,
			default: () => ({})
		}
	})
	// 拨打电话
	function payHanle(val) {
		console.log("拨打电话", val)
		if (val) {
			uni.makePhoneCall({
				phoneNumber: val, // 电话号码
				success: function () {
					console.log('拨号成功');
				},
				fail: function () {
					console.log('拨号失败');
				}
			});
		} else {
			uni.showToast({
				title: "还没有电话",
				icon: 'none'
			})
		}

	}
	// 去详情
	function goPath(){
		driverStore.nowItem = props.info
		uni.navigateTo({
			url: '/pages/drivers/missionDetail/missionDetail'
		})
	}
</script>

<style scoped lang="scss">
	.pull-number-item {
		margin-bottom: 20rpx;
		font-size: 24rpx;
		border-radius: 16rpx;
		background-color: #fff;
		overflow: hidden;

		.nameList {
			display: flex;
			padding: 20rpx;

			.nameItem {
				padding: 2rpx 16rpx;
				height: 40rpx;
				background: rgba(46, 135, 255, 0.1);
				border-radius: 4rpx 4rpx 4rpx 4rpx;
				border: 2rpx solid #2E87FF;
				display: flex;
				align-items: center;
				justify-content: center;

			}
		}

		.head {
			height: 72rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: linear-gradient(90deg, #C6DEFF 0%, #D9E9FD 100%);
			border-radius: 16rpx 16rpx 16rpx 0rpx;

			.left {
				padding: 20rpx;
				font-weight: 400;
				font-size: 22rpx;
				color: #2E87FF;

				.code {
					font-weight: bold;
				}
			}

			.cart-code {
				width: 170rpx;
				height: 69rpx;
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				border: 2rpx solid #2E87FF;
				font-size: 24rpx;
				color: #2E87FF;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.center-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 20rpx;

			.left {
				.addr-box {
					display: flex;
					align-items: center;

					&.end {
						margin-top: 20rpx;

						.icon-box {
							.icon {
								background-color: #39B791;
							}
						}
					}
				}

				.icon-box {
					display: flex;
					justify-content: center;
					align-items: center;
					margin-right: 8rpx;
					width: 44rpx;
					height: 44rpx;
					font-size: 20rpx;
					background-color: rgba(46, 135, 255, 0.1);
					border-radius: 50%;

					.icon {
						width: 32rpx;
						height: 32rpx;
						color: #fff;
						line-height: 32rpx;
						text-align: center;
						border-radius: 50%;
						background-color: $primary-color;

					}
				}
			}

			.right {
				.status-box {
					padding: 6rpx;
					width: 80rpx;
					height: 80rpx;
					color: $primary-color;
					text-align: center;
					line-height: 80rpx;
					border-radius: 50%;
					background-color: rgba(46, 135, 255, 0.1);
					transform: rotate(45deg);

					&.danger {
						color: $danger-color;
						background: rgba(235, 79, 81, 0.1);

						.status {
							background: rgba(235, 79, 81, 0.1);
						}
					}

					&.no {
						color: #2E87FF;
						background: rgba(46,135,255,0.1);

						.status {
							background:rgba(46,135,255,0.1);
						}
					}

					.status {
						border-radius: 50%;
						background-color: rgba(46, 135, 255, 0.1);
					}
				}
			}
		}

		.bottom-box {
			padding: 0rpx 20rpx;

			.bottom {
				margin-top: 12rpx;
				margin-bottom: 20rpx;
			}

			.item {
				padding: 14rpx 24rpx 18rpx;
				width: 100%;
				height: 100%;
				border-radius: 8rpx;
				background-color: #EFF6FE;
				box-sizing: border-box;

				.title {
					margin-bottom: 14rpx;
					color: #989DA5;
				}

				.val {
					font-weight: 500;
					display: flex;
					align-items: center;
					position: relative;

					.icon {
						position: absolute;
						right: -8rpx;
						width: 25rpx;
						height: 27rpx;
						margin-left: 30rpx;
					}
				}

				.primary {
					color: $primary-color;
				}
			}
		}
	}
</style>